class Father {
  static staticFatherName = 'FatherName';

  static staticGetFatherName = function () {
    console.log(Father.staticFatherName);
  };

  constructor(public name) {}

  getName(){
    console.log(this.name);
  }

  /** 原型上的属性*/
  get a(){
    return 456;
  }
}

// let x = new Father('ahhh'); //Father { name: 'ahhh' }
// console.log(x);

class Child extends Father{
  /** 实例上自己的属性,es7里也有,class-properties*/
  public loveJob = 'xxoo';
  /** 经常用于react类组件，这样的好处在于这里的this永远指向Child实例,这样我们就能拿到组件实例从而拿到上面的状态,而不是拿到绑定的那个dom元素*/
  // handleClick = () => {
  //   console.log(this)
  // };

  static staticChildName = 'ChildName';

  static staticGetChildName = function () {
    console.log(Child.staticChildName);
  };

  constructor(public name, public age) {
    super(name)
  }

  getAge(){
    console.log(this.age);
  }

}


let c1 = new Child('ahhh', '10');
c1.getName(); // ahhh
c1.getAge(); // 10
/** 没错,静态方法和属性也会继承,继承到子类自己身上(非实例身上)*/
Child.staticGetChildName(); // ChildName
Child.staticGetFatherName(); // FatherName
console.log(Child.staticChildName); // ChildName
console.log(Child.staticFatherName); // FatherName

console.log(c1.a); // 456
console.log(Father.prototype.hasOwnProperty('a')); // true
console.log(c1.hasOwnProperty('loveJob')); // true
